﻿using System.Collections.Generic;
using NHibernate;
using ParaEditor.Domain.Entities;
using System;

namespace ParaEditor.DAO.ParaDAO
{
    public class InnerVerCtrlDAO : BaseDAO
    {
        private static InnerVerCtrl obj = new InnerVerCtrl();

        public InnerVerCtrlDAO()
            : base(obj)
        {
        }


        public InnerVerCtrl GetInnerVerCtrlByParamIDAndParamNum(string paramID,int paramNum)
        {
            string sqlQuery = "select * from TBL_METRO_INNER_VER_CTRL t where can_issue = 1 and version_st = 1 and verify_st = 1 and version_num = " + paramNum + " and version_owner = '" + paramID + "'";
            try
            {
                ISQLQuery query = Session.CreateSQLQuery(sqlQuery).AddEntity(obj.GetType());
                IList<InnerVerCtrl> list = query.List<InnerVerCtrl>();
                if (list.Count != 0)
                {
                    return list[0];
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                return null;
                throw e;
                
            } 
        }
    }
}
